<template>
  <div class="goodsContent">
     <ul class="menu">
      <li v-for="item,index in goodsInfo" :key="item.name">
        <a :href="'#'+index">{{ item.name }}</a>
      </li>
    </ul>
    <ol class="list">
      <li v-for="(item,index) in goodsInfo" :key="item.name">
      <h3 :id="index">{{item.name}}</h3>
      <ul class="listCont">
        <li v-for="food in item.foods" :key="food.name">
           <div class="box">
            <div class="pic">
                <img :src="food.image" alt="" />
              </div>
              <div class="title">
                <h4>{{ food.name }}</h4>
                <span>{{food.description}}</span>
                <span>月售{{food.sellCount}}份&ensp;好评{{food.rating}}%</span>
                <div class="price"><span>￥{{ food.price }}</span>
                  <Btns :item="food" type="0"></Btns>
                </div>
              </div>
              
           </div>
        </li>
      </ul>
      </li>
    </ol>
    <!-- <div class="mask">
       <div class="box">
        <p class="p1">
            <span>购物车</span>
            <span>清空</span>
        </p>
        <ul class="boxList">
          <li v-for="item in carList" :key="item.name">
            {{item.name}}
            
          </li>
        </ul>
       </div>
    </div> -->
    <div class="shopCar">
       <!-- <div class="botm"> -->
        <p class="p1" @click="showCar">
        <img src="../../../img/shop.png" alt="">
        </p>
        <div>
          <p class="p2 ,istype:price" >￥{{ getPrice }}</p>
        <p class="p2">另需配送费4元</p>
        <p class="p2">20元起送</p>
        </div>
       <!-- </div> -->
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
import Btns from "./btns.vue";
export default {
  data() {
    return {
      // CarList: [],
      // num: 0,
    };
  },
  components: {
    Btns,
  },
  created() {
    this.getGoods();
  },
  computed: {
    ...mapState(["goodsInfo", "carList","price"]),
    getPrice() {
      let num = 0;
      // console.log(11)
      // console.log(this.carList)
      this.carList.forEach((item) => {
        num += item.price * item.count;
      });
      return num ;
    },
  },
  methods: {
    ...mapActions(["getGoods"]),
    showCar() {
      this.$store.commit("showCar");
    },
  },
};
</script>
<style  scoped>
*{
   margin: 0;
  padding: 0;
}
.goodsContent {
  display: flex;
  height: 600px;
  width: 400px;
  /* overflow: hidden; */
  margin: 0 auto;
  position: relative;
}
.menu{
  width: 85px;
    height: 530px;
    background-color: #f3f5f7;
}  
.menu li{
    position: relative;
    width: 85px;
    height: 56px;
    background-color: #f3f5f7;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    list-style: none;
    font-size: 13px;
    text-align: center;
   
  }
.menu a{
    color: black;
    text-decoration: none;
    /* border-bottom: 2px solid #9c9ea1; */
  }
.menu li::after{
  content: "";
  display: block;
  width: 70px;
  height: 2px;
  position: absolute;
  bottom: 0;
 border-bottom: 1px solid #d3d4d5;
}
.menu li:hover {
    background-color:white;
  }
.list {
  flex: 1 1 auto;
  overflow-y: scroll;
}

.list h3{
  border-left: 4px #d9dde1 solid;
  background: #f3f5f7;
  height: 26px;
  line-height: 26px;
  padding-left: 12px;
  color: rgb(147, 153, 159);
  font-weight: 400;
  font-size: 12px;
}

.list .listCont li {
  padding: 0 18px;
  position: relative;
}

.list .listCont .box {
  display: flex;
  padding: 18px 0;
  border-bottom: 1px rgba(1, 17, 27, 0.1) solid;
}

.list .listCont .box .pic img {
  width: 80px;
  height: 80px;
}

.list .listCont .box .title {
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  color: rgb(147, 153, 159);

}
.title h4{
  color: black;
}
.title span{
  margin-top: 5px;
} 
.title .price{
  width: 300px;
  display: flex;
  justify-content: space-between;
}
.title .price span{
  color: red;
  font-size: 18px;
  font-weight: 800;
}    
.mask{
  width: 100%;
  height: 801px;
  position: absolute;
  left: 0;
  bottom: 0;
  background-color: rgba(7, 17, 27, 0.5);
  backdrop-filter: blur(10px);
}  
.mask .box{
  width: 400px;
  height: 300px;
  position: absolute;
  left: 0;
  bottom: 70px;
  background-color: white;
  display: flex;
  flex-direction: column;

}
.mask .box p{
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
  height: 40px;
  background-color: #f3f5f7;
  line-height: 40px;
  color: rgb(66, 63, 63);
  border-bottom: 1px solid rgb(176, 176, 175);
}
.mask .box p span:nth-child(2):hover{
  color: rgb(0, 160, 220);
}
.mask .box .boxList{
  height: 360px;
  background-color: rgb(200, 129, 129);
}
  .shopCar{
    position: absolute;
    bottom: 0;
    left: 0;
    width: 400px;
    /* background: blue; */
    height: 70px;
    z-index: 200;
    display: flex;
    background-color: black;
    color: rgba(255, 255, 255,0.4);
    font-size: 15px;
    /* position: relative; */
    /* padding-left: 75PX; */
  }
  .shopCar .p1{
    width:65px ;
    height: 65px;
    border-radius: 50%;
    background-color: black;
    position: absolute;
    top: -16px;
    left: 8px;
  }
  .shopCar .p1 img{
    width:50px ;
    height: 50px;
    border-radius: 50%;
    margin: 8px 8px;
  }
  .shopCar div{
    flex: 1;
    padding-left: 75PX;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .shopCar .p2{
    width: 70px;
    height: 70px;
    line-height: 70px;
    margin-right: 10px;
    text-align: center;
    /* background-color: royalblue; */
  }
  .shopCar .p2:hover{
    background-color: rgba(255, 255, 255, 0.4);
  }
</style>
